package view
{
	
	import flash.display.*;
	import flash.text.*;
	
	import manager.ViewMgr;
	import model.ExplorePx;
	import event.Evt;
	
	/**
	 * -- StageDetailView --
	 * @desc	view to show detail of a stage
	 * @author	Aqua (built on 2011-11-25)
	 */
	public class StageDetailView extends BaseView
	{
		//---------------------//
		//     Constructor     //
		//---------------------//
		
		/**************************************************************************
		 * -- StageDetailView --
		 * @desc		constructor
		 * @param		main view object of this view class
		 *************************************************************************/
		public function StageDetailView(viewComponent:DisplayObjectContainer):void
		{
			super(viewComponent);
			
			_viewComponent.name = VIEW_NAME;
			_explorePx = getPx(ExplorePx.NAME) as ExplorePx;
			
			addAddCmd("txt_name",			add_txt_name);
			addAddCmd("txt_desc",			add_txt_desc);
			addAddCmd("txt_num_level",		add_txt_num_level);
			addAddCmd("txt_num_challenge",	add_txt_num_challenge);
			addAddCmd("txt_num_complete",	add_txt_num_complete);
			addAddCmd("txt_bonus",			add_txt_bonus);
			addAddCmd("btn_start",			add_btn);
			addAddCmd("btn_return",			add_btn);
			
			addClickCmd("btn_start",		click_btn_start);
			addClickCmd("btn_return",		click_btn_return);
		}
		
		/**************************************************************************
		 * -- onAdd --
		 * @desc		override function, get xml when added to stage
		 *************************************************************************/
		public override function onAdd():void
		{
			_xml = _explorePx.getStageXML(_explorePx.chosenStage);
			super.onAdd();
		}
		
		
		//------------------//
		//     Privates     //
		//------------------//
		
		//-- Add Handlers --//
		private function add_txt_name():void
		{
			TextField(_display).text = _xml.name;
		}
		private function add_txt_desc():void
		{
			TextField(_display).text = _xml.desc;
		}
		private function add_txt_num_level():void
		{
			TextField(_display).text = _xml.num_level;
		}
		private function add_txt_num_challenge():void
		{
			
		}
		private function add_txt_num_complete():void
		{
			
		}
		private function add_txt_bonus():void
		{
			
		}
		private function add_btn():void
		{
			makeBtn(_display);
		}
		
		//-- Click Handlers --//
		private function click_btn_start():void
		{
			_explorePx.enterStage();
			_evt.dispatch(Evt.ENTER_STAGE);
		}
		private function click_btn_return():void
		{
			_evt.dispatch(Evt.RETURN_TO_LIST);
		}
				
		
		public static const VIEW_NAME	:String = "STAGE_DETAIL_VIEW";
		public static const LAYER_INDEX	:int	= 2;
		
		private var _explorePx	:ExplorePx;
		private var _xml		:XML;
	}
	
}